Fix local LoRA weight auto-discovery in offline mode#14204
Merged
sayakpaul merged 2 commits intoJul 16, 2026
Conversation
sayakpaul
reviewed
Jul 16, 2026
fropych
marked this pull request as ready for review
July 16, 2026 09:19
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #14195
_best_guess_weight_name()currently checkslocal_files_onlyandHF_HUB_OFFLINEbefore determining whether the supplied path is a local file or directory. As a result, local LoRA weights without an explicitweight_nameare rejected in offline mode before Diffusers inspects the local filesystem.This PR moves the offline-mode guard after the local file and directory checks. With this change:
HF_HUB_OFFLINE=1orlocal_files_only=True;weight_namestill raises the existing offline-mode error;model_info()is not called in offline mode.Checking
os.path.isfile()andos.path.isdir()only accesses the local filesystem and cannot trigger a Hub request, so this preserves the network restrictions of offline mode. There are no public API changes.Coordination: #14195 and the related discussion in #14198.
Tests
The regression tests cover local files, local directories, both offline controls, remote repository IDs without
weight_name, the absence ofmodel_info()calls, and the existing behavior for zero or multiple matching files.AI assistance
This PR received substantial assistance from OpenAI Codex. I identified and reproduced the original problem, defined the expected behavior and regression cases, and made the final contribution decisions. Codex was used to inspect the repository instructions and related history, implement the minimal fix, add regression tests, run the relevant checks, perform the final self-review, and help draft the PR description. The final diff and test results were presented to me before submission.
Final self-review
Before submitting
self-reviewskill on the diff?Who can review?
@sayakpaul